package chapter20;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

/**
 * @program: exercise
 * @description: Iterator迭代器
 * @author: 陈庆彪
 * @create: 2020-02-21 10:32
 **/
public class TestIterator {
    public static void main(String[] args) {
        Collection<String> collection=new ArrayList<>();
        collection.add("北京");
        collection.add("上海");
        collection.add("武汉");
        collection.add("南京");
        collection.add("杭州");

        Iterator<String> iterator=collection.iterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next().toUpperCase()+" ");
        }
        System.out.println();
    }
}
